// ============================================================================
// KEXIO Forum Authentication Module Styles
// - Minimalist black and white design inspired by modern web aesthetics
// ============================================================================

// ------------------------------
// CSS Variables & Configuration
// ------------------------------
:root {
  --kx-primary: #000000;
  --kx-secondary: #ffffff;
  --kx-accent: #f5f5f5;
  --kx-text-light: #666666;
  --kx-text-lighter: #999999;
  --kx-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --kx-button-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --kx-button-hover-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  --kx-border-radius: 12px;
  --kx-border-radius-large: 16px;
  --kx-transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

// ------------------------------
// Animations & Keyframes
// ------------------------------
@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes slideUp {
  0% { 
    transform: translateY(20px); 
    opacity: 0; 
  }
  100% { 
    transform: translateY(0); 
    opacity: 1; 
  }
}

@keyframes pulseSubtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

// ------------------------------
// Main Login Container
// ------------------------------
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--kx-accent);
  font-family: 'Inter', 'system-ui', sans-serif;
  color: var(--kx-primary);
  animation: fadeIn 0.6s ease-in-out;
}

// ------------------------------
// Header Logo Section
// ------------------------------
.login-header {
  padding: 16px 0; /* 减少header padding以节省垂直空间 */
  background: var(--kx-secondary);
  border-bottom: 1px solid #f3f4f6; /* border-gray-100 */
  display: flex;
  align-items: center;
  justify-content: center;

  .container {
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .logo-title {
    font-size: 48px; /* text-3xl */
    font-weight: bold;
    color: var(--kx-primary);
    text-decoration: none;
    letter-spacing: -0.025em; /* tracking-tight */
    transition: all 0.3s var(--kx-transition-smooth);

    &:hover {
      opacity: 0.8;
    }

    .logo-subtitle {
      color: var(--kx-text-light);
      font-weight: 400;
    }
  }
}

// ------------------------------
// Main Content Area
// ------------------------------
.login-main {
  flex: 1; /* flex-grow */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px; /* 减少padding避免滚动条 */
  min-height: 0; /* 确保flex子项可以收缩 */
}

// ------------------------------
// Login Card
// ------------------------------
.login-card {
  width: 100%;
  max-width: 448px; /* max-w-md = 448px */
  background: var(--kx-secondary);
  border-radius: 16px; /* rounded-2xl */
  box-shadow: var(--kx-card-shadow);
  padding: 20px; /* 减少内边距避免滚动条 */
  animation: slideUp 0.6s ease-out; /* animate-slide-up */
  
  .login-title {
    font-size: 32px; /* text-2xl */
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px; /* 减少标题底部间距 */
    color: var(--kx-primary);
  }

  // ------------------------------
  // Form Item Spacing
  // ------------------------------
  .el-form-item {
    margin-bottom: 16px; /* 减少间距避免滚动条 */

    &:last-child {
      margin-bottom: 0; /* 最后一个表单项无底边距 */
    }

    &:has(.remember-me) {
      margin-bottom: 20px; /* 记住我项稍大间距 */
    }
  }

  // ------------------------------
  // Form Elements Styling
  // ------------------------------
  .form-label {
    display: block;
    color: var(--kx-text-light);
    margin-bottom: 8px; /* mb-2 */
    font-size: 14px;
    font-weight: 400;
  }

  .password-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px; /* mb-2 */
    width: 100%; /* 确保容器占满宽度 */
    min-height: 20px; /* 确保最小高度避免重叠 */

    .form-label {
      flex-shrink: 0; /* 防止标签收缩 */
      margin-bottom: 0; /* 重置margin避免影响layout */
    }

    .forgot-password {
      font-size: 13px; /* 稍微减小字体避免空间不够 */
      color: var(--kx-text-light);
      text-decoration: none;
      transition: color 0.3s ease;
      white-space: nowrap; /* 防止文本换行导致重叠 */
      flex-shrink: 0; /* 防止链接被压缩 */
      margin-left: 16px; /* 确保与标签有足够间距 */

      &:hover {
        color: var(--kx-primary);
      }
    }
  }

  .form-input {
    .el-input__wrapper {
      height: 48px; /* py-3 = 12px * 2 + line-height */
      border-radius: 8px; /* rounded-lg */
      border: 1px solid #e5e7eb; /* border-gray-200 */
      box-shadow: none;
      transition: all 0.3s ease;
      padding-left: 16px; /* 调整以适应增加的图标左边距 */
      padding-right: 16px; /* pr-4 */

      &:hover {
        border-color: #d1d5db; /* hover state */
      }

      &.is-focus {
        border-color: var(--kx-primary);
        box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05); /* input-focus */
      }
    }

    .el-input__inner {
      height: 46px;
      line-height: 46px;
      font-size: 16px;
      padding-left: 0;
      padding-right: 0;

      &::placeholder {
        color: #9ca3af; /* placeholder color */
      }
    }

    .el-input__prefix {
      left: 20px; /* 增加图标左边距 */
      display: flex;
      align-items: center;
      color: var(--kx-text-light);
    }

    .el-input__suffix {
      right: 16px; /* pr-4 */
    }
  }

  // ------------------------------
  // Remember Me Checkbox
  // ------------------------------
  .remember-me {
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* 减少底边距避免滚动条 */
    
    .el-checkbox__input {
      .el-checkbox__inner {
        width: 16px; /* w-4 */
        height: 16px; /* h-4 */
        border-radius: 2px;
      }

      &.is-checked .el-checkbox__inner {
        background-color: var(--kx-primary);
        border-color: var(--kx-primary);
      }
    }

    .el-checkbox__label {
      margin-left: 8px; /* ml-2 */
      font-size: 14px; /* text-sm */
      color: var(--kx-text-light);
    }
  }

  // ------------------------------
  // Login Button
  // ------------------------------
  .login-button {
    width: 100%;
    height: 48px; /* py-3 */
    background: var(--kx-primary);
    border: none;
    border-radius: 8px; /* rounded-lg */
    color: var(--kx-secondary);
    font-size: 16px;
    font-weight: 500; /* font-medium */
    margin-bottom: 0;
    box-shadow: var(--kx-button-shadow);
    transition: all 0.3s ease; /* btn-hover transition */

    &:hover {
      transform: translateY(-2px);
      box-shadow: var(--kx-button-hover-shadow);
      background: var(--kx-primary);
    }

    &:active {
      transform: translateY(0);
      box-shadow: var(--kx-button-shadow);
    }
  }

  // ------------------------------
  // Divider Line
  // ------------------------------
  .divider {
    display: flex;
    align-items: center;
    margin: 20px 0; /* 减少上下间距避免滚动条 */
    position: relative;

    &::before,
    &::after {
      content: '';
      flex: 1;
      height: 1px;
      background: #e5e7eb; /* bg-gray-200 */
    }

    .divider-text {
      padding: 0 16px; /* px-4 */
      font-size: 14px; /* text-sm */
      color: var(--kx-text-light);
      background: var(--kx-secondary);
    }
  }

  // ------------------------------
  // Social Login Buttons
  // ------------------------------
  .social-login {
    display: flex;
    justify-content: center;
    gap: 24px; /* space-x-6 */
    margin-bottom: 16px; /* 减少底边距避免滚动条 */

    .social-btn {
      width: 48px; /* w-12 */
      height: 48px; /* h-12 */
      border: 1px solid #e5e7eb; /* border-gray-200 */
      background: var(--kx-secondary);
      color: var(--kx-primary);
      transition: all 0.3s ease; /* btn-hover transition */
      border-radius: 50%; /* rounded-full */
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background: var(--kx-accent); /* hover:bg-accent */
        border-color: var(--kx-primary);
        transform: translateY(-2px);
        box-shadow: var(--kx-button-shadow);
      }

      &:active {
        transform: translateY(0);
        box-shadow: var(--kx-button-shadow);
      }

      i {
        font-size: 20px; /* text-xl */
      }
    }
  }

  // ------------------------------
  // Register Link
  // ------------------------------
  .register-link {
    text-align: center;
    margin-bottom: 0;

    p {
      margin: 0;
      font-size: 14px;
      color: var(--kx-text-light);
    }

    .register-text {
      color: var(--kx-primary);
      font-weight: 500; /* font-medium */
      text-decoration: none;
      transition: color 0.3s ease;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  // ------------------------------
  // Tips Message
  // ------------------------------
  .tips {
    font-size: 12px;
    color: var(--kx-text-light);
    background: var(--kx-accent);
    padding: 8px 12px;
    border-radius: var(--kx-border-radius);
    margin-top: 16px;
    text-align: center;
  }
}

// ------------------------------
// Login Footer
// ------------------------------
.login-footer {
  padding: 16px 0; /* 减少footer padding以节省垂直空间 */
  background: var(--kx-secondary);
  border-top: 1px solid #f3f4f6; /* border-t border-gray-100 */

  .container {
    margin: 0 auto;
    padding: 0 16px; /* px-4 */
    text-align: center;
  }

  p {
    margin: 0 0 8px 0; /* mt-2 */
    font-size: 14px; /* text-sm */
    color: var(--kx-text-light);
  }

  .footer-links {
    display: flex;
    justify-content: center;
    gap: 24px; /* space-x-6 */
    margin-top: 8px; /* mt-2 */

    .footer-link {
      font-size: 14px; /* text-sm */
      color: var(--kx-text-light);
      text-decoration: none;
      transition: color 0.3s ease; /* transition-colors */

      &:hover {
        color: var(--kx-primary); /* hover:text-primary */
      }
    }
  }
}

// ------------------------------
// Password Input with Toggle
// ------------------------------
.password-toggle {
  cursor: pointer;
  color: var(--kx-text-light);
  transition: color 0.3s ease;

  &:hover {
    color: var(--kx-primary);
  }
}

// ------------------------------
// Responsive Design
// ------------------------------
@media (max-width: 768px) {
  .login-header .logo-title {
    font-size: 40px; /* Smaller on tablet */
  }

  .login-main {
    padding: 16px; /* 进一步减少padding避免滚动条 */
  }

  .login-card {
    padding: 16px; /* 进一步减少内边距避免滚动条 */
    
    .login-title {
      font-size: 28px; /* Smaller title */
      margin-bottom: 16px; /* 减少标题间距 */
    }

    .el-form-item {
      margin-bottom: 12px; /* 减少表单项间距 */
    }

    .password-label {
      .forgot-password {
        font-size: 12px; /* 平板上进一步减小字体 */
        margin-left: 12px; /* 调整间距 */
      }
    }

    .social-login {
      gap: 16px;

      .social-btn {
        width: 40px;
        height: 40px;

        i {
          font-size: 18px;
        }
      }
    }
  }

  .login-footer .footer-links {
    flex-wrap: wrap;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .login-header {
    padding: 12px 0; /* 进一步减少头部padding避免滚动条 */

    .logo-title {
      font-size: 32px;
    }
  }

  .login-main {
    padding: 12px; /* 最小的padding */
  }

  .login-card {
    padding: 12px; /* 最小的内边距避免滚动条 */

    .login-title {
      font-size: 24px;
      margin-bottom: 12px; /* 最小标题间距 */
    }

    .el-form-item {
      margin-bottom: 10px; /* 最小表单间距避免滚动条 */
    }

    .password-label {
      flex-direction: row; /* 确保水平布局 */
      gap: 8px; /* 使用gap代替margin确保间距 */
      
      .form-label {
        font-size: 13px; /* 手机端减小标签字体 */
      }

      .forgot-password {
        font-size: 11px; /* 手机上最小字体避免重叠 */
        margin-left: 0; /* 重置margin，使用gap */
      }
    }

    .social-login {
      gap: 12px;
      margin-bottom: 12px; /* 最小社交登录底边距 */

      .social-btn {
        width: 36px;
        height: 36px;

        i {
          font-size: 16px;
        }
      }
    }

    .divider {
      margin: 12px 0; /* 最小分隔线间距 */
    }
  }

  .login-footer {
    padding: 12px 0; /* 最小底部padding避免滚动条 */

    .footer-links {
      flex-direction: column;
      gap: 8px;
    }
  }
}

// ------------------------------
// Print Styles
// ------------------------------
@media print {
  .login-container {
    background: white !important;
    min-height: auto;
  }

  .login-card {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }

  .login-button,
  .social-login {
    display: none !important;
  }
}
